//导入request.js请求工具
import request from '@/utils/request.js'

// 用户注册
export function userRegisterService(registerData) {

    //借用UrlSearchParams完成传递
    const params = new URLSearchParams()
    for (let key in registerData) {
        // console.log(key,registerData[key]);
        params.append(key, registerData[key]);
    }

    return request.post('/user/register', params);
}

// 用户登录
export function userLoginService(loginData) {
    const params = new URLSearchParams()
    for (let key in loginData) {
        // console.log(key,loginData[key]);
        params.append(key, loginData[key]);
    }

    return request.post('/user/login', params);
}

// 获取用户详细信息
export function userInfoService(){
    return request.get('/user/userInfo')
}

// 更新用户信息
export function userInfoUpdateService(newInfoData){
    return request.put('/user/update',newInfoData);
}

// 更新密码
export function userInfoResetPassword(params){
    return request.put('/user/updatePwd',params)
}
